Skip to content

feat(cil): migrate execution and proof bindings to decoded CIL - #602

Draft
benaadams wants to merge 1628 commits into
mainfrom
feat/canonical-cil
Draft

benaadams wants to merge 1628 commits into
mainfrom
feat/canonical-cil

Conversation

@benaadams

@benaadams benaadams commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Tracks #568, #582, #596, #597 and #598. Methods decode from pinned bodies. Unsupported reachable instructions block extraction.

Implemented

  • Lean binds scalar generic calls to a unique pinned MethodDef, public sidecar export and audited contract closure.

  • TypeDef, ClassLayout, Field and FieldLayout bind scalar structs. Moving a field or changing packing refutes both readers (0 returned, 128 required).

  • Class slots bind inherited targets and local MethodImpl rows alongside unrelated IDisposable implementations. Missing slots and crossed owners or declarations fail. The mutant returns 11 instead of 12.

  • GenericParam and GenericParamConstraint bind method and owner constraints. Pair<int,long> selects !1 via InterfaceImpl and rejects !0 and !2. Both constrained calls return x + 2 for all Int32 inputs and preserve memory.

  • A facade ExportedType and AssemblyRef bind the implementation TypeDef. Its caller returns x + 1 for every Int32. Thirteen metadata mutations fail.

  • Portable 256/512-bit equality preserves memory. Repeating the left operand refutes both at the top bit. Reuse costs 6,015 kernel heartbeats vs 767,330/977,114 directly.

  • Removed C# field/frame records, DivRem64, Intrinsic, Jump, ObjectInstruction, ScalarIntrinsic, Call and Constant. 108 outlines and 12,667 decisions match.

  • x64 and ARM64 AES satisfy one round contract for every state and key. Repeating the low key half gives a verified one-bit counterexample on both profiles.

  • Closed typeof retains both ldtoken/getter pairs and comparison or branch. Four changed System.Type signatures fail. Five-step SegmentRun accepts any frame, stack and memory. Three compiled methods cover all Int32 inputs and match 15 CLR results. Other costs 2,299,693 heartbeats shared, 2,411,159 directly and 1,158,900 folded.

  • ldstr pushes its bound reference. MemoryOp.stringLiteral is deleted. An unbound literal is inconclusive for CLR contracts.

  • CI runs 81 suites in 14 groups.

  • Both readers require an earlier nonzero enclosing TypeDef. Strict binding checks generic bases and field ranges. Structs and enums bind core scope, token and neutral culture. Pinned .NET 11 CoreLib fixes primitive storage and stack widths and its fieldless System.Object terminates layout. The kernel checks long assembly identities.

  • Templates share callee numbering and report the first differing pc. Compiled ldftn binds its index. A two-assembly struct call binds owner, token and arguments (2,713,469 kernel heartbeats both ways). Seven call and field extractions and outlines match. Renamed or reindexed stores fail at pc 1.

  • Lean checks tiny and fat method headers, instruction bytes, operands, branch targets, stack depth and local initialization. decodeSingleCatch also reads one small typed catch, checks its class token and disjoint instruction-aligned byte ranges. The public verifier rejects exception sections. The CoreLib resource lookup has a 56-byte body with a 25-byte instruction stream.

  • Check method identities, signatures, locals, generic constraints, type operands, fields and call targets against carried metadata. Object parameters bind the core scope and name. Nongeneric forwarded calls bind open signatures in the caller and closed signatures in the defining module. Four scope mutations fail. Shared indexes avoid repeated scans. Omitted heap entries distinguish zero and maximum-width offsets.

  • Method.argumentAccess reads arguments from the declared signature and homes. Its method{n}_argumentAccess{i} facts and reduceArgumentAccess simproc cost about 8,400 kernel heartbeats per argument at 8, 32 and 128 arguments (10,800 with homes). The lookups suite rejects quadratic growth.

  • Feature certificates store known words as sorted local-index and word pairs. Kernel heartbeats per instruction at 16, 64 and 256 locals are 21,719, 21,832 and 22,048, down from 23,163, 28,471 and 52,354. FeatureFlowValid.expand and FeatureListValid.known prove equivalence to the one-fact-per-local specification.

  • Native method-table loads check the index against the proved entry count (entryCount and counted on both table types). At 16/64/256 entries they cost 24,722/24,714/24,753 kernel heartbeats, previously 29,483/41,785/90,934. Cost remains linear in static bindings and the loaded index.

  • Class and static field instructions carry FieldRef. FieldRef.ofOperand? reads its owner, index, type and metadata name. Templates emit their links.

  • ldarg uses Method.argumentAccess. argumentAccess_of_evidence proves unhomed narrowing. Outlines read parameter home slots directly. Starg, Ldarga and SlotOperations are deleted. 45 stepping rows stayed within 2%.

  • Instruction.ofRaw? checks ECMA-335 opcodes and their operands. The kernel checks the raw forms in Tests/ValueDecoding.lean. At 500/2,000/8,000 instructions, decoding costs 14,043/14,015/14,007 heartbeats per instruction.

  • ldftn pushes a scoped method pointer. calli checks its signature, target and tail. prefix. ManagedOp is deleted. Generated proofs use step_managed_call_eq and cil_kernel_rfl and pass the 400-byte owner fixture.

  • ManagedCallsValid checks ascending call-site keys in one pass. ManagedCallsValid_iff_original proves equivalence to the list check. Cost per site falls slightly at 64–1,024 sites. The old per-site scan grew 3.23 times at 64–256.

  • Tests/Objects.cs verifies its 38 example proofs in one generated batch, as 22 other test files do; locally the file went from 676 s to between 107 and 163 s.

  • The declared signature is checked by its own conjunct of MethodEvidenceValid, DeclaredValid, proved by rfl in the generated method{n}_declared_validated. On a 16-method fixture the shape theorems went from 4,211,835 to 774,006 heartbeats and the declared theorems add about 11,250 per method.

  • The object identity and null-test arms of Safety.step sit in its first match, so neither match exceeds the 79 alternatives split handles. The 91 generated step equations state the same facts. step_raise_faulting costs 7.1% more and has a raised heartbeat budget.

  • Method.ofRaw? uses Instruction.ofRaw? and the checked frame, signature and home computations. Method.ofBody? reads code and initialization from pinned bytes after checkBody. decodedProgram? does this for every method. Method.ofBody?_of_decodes uses the generated body check. At 500/2,000/8,000 instructions decoding costs 24,775/24,494/24,425 kernel heartbeats per instruction.

  • Examples/Proofs/DecodedAdd.lean proves correctness_decoded: the program that decodedProgram? reads from the bytes of Arithmetic::Add returns the sum of its arguments modulo 2^64. The proof names neither the emitted method nor the emitted program, and changing the add byte to sub in the extraction makes it fail. It costs 1.87M heartbeats and 479,000 kernel heartbeats, 1.38 and 1.24 times the proof over the emitted method.

  • localloc is a CIL instruction: Instruction.stackAlloc is deleted, the zeroing flag is DeclaredSignature.initLocals, which DeclaredValid ties to the localsinit bit of the body, and Instruction.ofRaw? decodes opcode 0xFE0F.

  • A call site states its method once, as a typed MethodRef (owner, metadata name, signature, generic arity and method arguments); the declaring type, return type and parameter types are read from it. checkCallOperand requires the name to spell the metadata row name, and the generic arity and method arguments to equal the row and the site. The name clause costs 41,199 and 151,448 heartbeats at 20 and 80 bytes, linear per byte.

  • Indirect accesses bind the raw width, signedness and alignment. All 39 forged emissions fail and all 25 extractor emissions pass. Unsupported ldobj and stobj types admit only the span no-op. Decoded cpblk and initblk execute directly. The 308 block checks cover alignment, bounds, overlap and zero counts. Lean proves a fill past the allocation cannot succeed.

  • Every raw opcode decodes to its admitted instruction or an explicit hole carrying the opcode. Stepping a hole faults. Instruction.ofRaw? and Instruction.ofRaw take the preceding instruction for prefixes. Instruction.ofRawCode carries it in one pass. Method.ofRaw? rejects undeclared arguments, Method.ofRaw?_code identifies the decoding at each pc, and ScalarFlowValid.instruction_checked proves the match.

  • fixedBytes joins chunks of at most 256 bytes through fixedDigitsWithin, avoiding kernel hash collisions on equal low 64 bits. At 125, 500 and 1,000 string tokens the body check costs 88,900, 92,700 and 99,800 heartbeats/instruction (previously 89,600, 136,300 and 201,500). At 5, 10 and 20 KB the per-byte growth bound is 1.15. Body obligations up to 256 bytes grew 0.06–0.46%. Binding pages use 512-byte chunks. A 4 KB page costs 23.26M heartbeats with equal chunk tails and 23.25M with random tails (previously 506.1M and 23.0M). Importing the prelude-only CIL/Extraction/FixedDigits.lean costs 1.92M heartbeats and 1.2 s for a generated audit module, down from 5.25M and 2.9 s. Tests/BodyLiteral.lean checks the import closure.

  • PrefixEntryFree forbids a branch or switch from skipping unaligned., volatile., tail., constrained., no. or readonly. at any pc. checkBody_prefixEntryFree, instantiateMethod_prefixEntryFree and MethodEvidenceValid.prefixEntryFree transfer this decoder guarantee to every validated method. prefixEntryFreeWith scans a branch-destination bit mask at about 1,380 heartbeats per instruction. Cecil extraction also rejects entry after a prefix. All corpus and fixture methods pass.

  • A homed argument is stored with starg, addressed with ldarga and read with ldarg; the lowered local forms for homes are gone, and the four raw forms decode. step_relabel_faulting is proved by splitting on the first match of step and costs 52,100 heartbeats where it cost 212,700.

  • Method.fieldShape and Method.valueShape resolve a typed field reference or a value type against the layout environment, with one generated fact per distinct operand that the kernel checks from one layout entry: 268,814 to 271,626 heartbeats per field fact and 13,294 to 16,135 per value fact from 8 to 512 structs. No instruction reads them yet.

  • A raised exception is a typed ExceptionType, in instructions, faults, contracts and example proofs; text is produced for display only.

  • The receiver fold is deleted: a raw stloc and ldloca before a span get_Length or get_Item call are emitted as themselves and checked against their raw instructions.

  • StepMetadata requires equal layout environments, and a method signature with an explicit receiver is refused in Lean by instantiation and by the metadata identity check; the declared signature check costs 9,883, 9,890 and 9,939 heartbeats per method at 1, 4 and 16 parameters.

  • Byte lists in generated evidence are numerals read by CIL.Extraction.fixedBytes instead of list literals: checking a generated file costs 29% (Add), 25% (Countdown) and 17% (Struct) fewer heartbeats in total, and the kernel part rises 3 to 6% because each check decodes its bytes.

  • MetadataName.ofBytes? reduces in the kernel in time linear in the name: 13,498, 35,148 and 119,302 heartbeats at 20, 80 and 320 bytes, where it cost 143,456, 1,746,460 and 26,147,681.

  • BindingAudit.metadataRows checks carried metadata and #US entries. A forged page fails. BindingAudit.staticData checks each static operand's Field, FieldRVA, signature, size, packing and mapped bytes. The compiled table returns 17. A matching prefix, reversed bytes and a missing RVA marker fail. Deep results under --proof-root bind the compiled import closure. Failed publication creates no receipt or cache entry. The TypeDef reader checks name, kind, fields, base and nesting, including the sorted NestedClass rows.

  • BindingAudit.publicKeyTokens checks Assembly keys and AssemblyRef keys or tokens against direct references. Malformed references fail even if others are missing. objectFields checks System.Object has no instance fields. tupleFields checks the pair TypeDef, both GenericParams and Item1/Item2 FIELD VAR signatures. Separate images work. Missing destinations leave facts uncovered. Rehashed Object fields and swapped tuple signatures fail. .NET 11 replay took 68.3 s and 79.9 s.

  • A support result is keyed by the extraction it was computed for, so a changed extraction no longer reuses the support of another one.

  • The proofs of Guards::Count and Guards::Index close again and Tests/Guards.cs runs in the evidence suite. Tests/HoleCorpus.cs pins that no admitted corpus method gets a parameter home from dead code or holds a dead prefix other than unaligned..

  • The extractor emits cil_decoded_method with Method.ofClosed? for every admitted method. The generated theorem identifies the complete method with the decoder result. The body certificate binds it to the selected assembly. Dead positions retain their raw opcode, and a reachable decoding refusal stops extraction.

  • Raw ldind and stind are the instructions ldind and stind over a numeric kind; load64, store64 and tableLoad are deleted.

  • ldnull, castclass and isinst are instructions with decode arms; objectTest and the memory operation nullObject are deleted. Method.ofRaw? decodes the instantiated code.

  • LayoutUse contains only struct constructions, locals and parameter homes. Canonical field instructions use the checked field reference. The same vector field resolves at byte 32 on x64 and byte 16 on ARM64. A swapped architecture table, owner or field type is rejected.

  • Struct ldflda uses the offset from its checked field layout. The offset-only Instruction.fieldAddress is removed. step_ldflda_struct_eq states the general step. step_ldflda_reference_eq and step_ldflda_readOnlyReference_eq preserve the receiver capability and use the checked pointer addition. Nested structs execute ldfld and stfld at the checked field offset and width. Both preserve padding flags. A store through a readonly reference faults even for a malformed value. Decoded ldfld and stfld now also replace fieldAt and setFieldAt.

  • Class and struct fields use ldfld, ldflda and stfld over FieldRef (opcodes 123–125). Method.fieldShape reads the checked layout. Instruction.instanceField? replaces classField?. Six class field operations, their checks and translator arms are deleted. Stores require the field’s stack kind. Names come from metadata rows. Goals with .fieldAt 4 4 false or .setAggregateFieldAt 8 4 now name the field in .ldfld or .stfld. Across 35 extractions kernel heartbeats rise 0.78% and total heartbeats fall 0.05%.

  • Static field access is ldsfld, ldsflda, stsfld and field ldtoken over a FieldRef; the static memory operations are deleted, the static field tie compares the field name, and the stepper builds a static read from the body's site fact. These four instructions have no decode arm yet.

  • newarr carries its raw type token and steps through the element shape the layout environment gives it; newArray and newReferenceArray are deleted, and a System.Object element array is refused by identity.

  • Call targets are read from each method's link table: the call arms of step take their target from the link of their pc and fault with unlinkedCall without one, and cil_instruction_equations states a link fact per call site.

  • step runs models through intrinsicCall, featureCall and related functions. MethodEvidenceValid.modelsAgree binds calls to typed entries using decoder and feature-flow evidence. memory_stepRenamed covers all memory operations. RuntimeModel.StepRenamed takes source well-formedness and an observable step. The 70 BitModels entries cover BitOperations, integer helpers and BinaryPrimitives.ReverseEndianness, excluding signed Log2 and signed 8- and 16-bit rotations. Outlines step the four bit counts through their calls.

  • A fault the model does not cover refutes nothing: ExecutionFault.definite is false for an unsupported instruction and for fuel exhaustion, Settled requires a definite fault, and the refutation lemmas take Settled. A refutation is a counterexample: MethodContract.Refuted, OutcomeContract.Refuted and OutcomeContract.RefutedCLR carry an input and memory that meet the precondition with a settled outcome the contract does not allow, or exhaustion at every budget (Diverges). The theorem audit and the gate runner accept a refutation only as one of these, matched by name and declaring module; a theorem stating Not of a contract's Holds, which a run that reaches a hole can prove, is refused (Tests/FailureReporting.cs keeps the forged proof that verified before).

  • Opcode 0x73 decodes to newobj of its constructor’s MethodRef. This removes newAggregate, newObject, their translator records and step lemmas. The decoder and evidence share method{n}Links. ManagedCallsValid binds a live constructor to its raw site, target, class or aggregate link, bases and size. Tests reject a forged or missing link, wrong kind, base list, size, opcode or owner. Span and exception constructors keep their literal models.

  • Opcode 0x28 decodes to call of a MethodRef and CallPrefixes for tail. and constrained.. The reference gives the argument count and the link at the pc gives the target. Instruction.ofCallSite? handles call and newobj. Method.ofRaw?, Method.ofBody? and decodedProgram? take links after the environment. Method.withCode clears them. ManagedCallsValid checks the direct target and token. Extraction checks operands and prefixes for targets, imports and runtime models. Template code and link equations allow arbitrary callee indices. Only proof outlines build C# operation lists. Six compiled fixtures produced byte-identical extractions and outlines.

  • Typed runtime calls cover integer Math helpers (Min, Max, Clamp, Abs, Sign; 31 corpus and 44 example sites), Vector128.CreateScalarUnsafe and 128/256-bit GetElement on ulong (23 example sites). A model checks the operands it observes. Linked calls keep the guard in step_call_linked. reduceRuntimeModel resolves a closed method under a variable environment. step_call_intrinsic steps the resolved call. Earlier intrinsic rows used 32% fewer frontend and 71% fewer kernel heartbeats; virtual calls cost about 61,000 heartbeats per table entry.

  • An admitted throw sequence executes each ldnull. Four compiled fixtures reject erasure. Lean checks the declared instance convention, parameter and return types, and generic arity of exception constructors. Eight altered operands fail the feature certificate. Four also fail on the compiled fixture. String loads and constructors still fold. Faults retain their type and raw throw position.

  • The direct Instruction.intrinsic and its execution rules are removed. C# outlines no longer carry SpanEmpty, ObserveView, ViewQuery, SpanSource, SpanCreate, SpanFromReference or SpanSingleReference. Array spans retain the element, mutability and range an outline uses.

  • step_call_eq states a call step as callStep of the link at its pc, a regular definition, and every call-family step rewrites its link fact in the pass that applies its step equation. With a match on the link in the equation the kernel evaluated the table read once per site, and the calls stepping row cost 10,827, 16,474 and 47,170 kernel heartbeats per instruction at 16, 64 and 256 instructions. The row now costs 7,131, 5,397 and 4,963 kernel heartbeats (7,742, 5,800 and 5,315 before the conversion) and 801,548, 817,861 and 822,727 frontend heartbeats (821,255, 840,326 and 846,190).

  • The stepper rewrites the link fact of a newobj step in the pass that applies its step equation, so only the arm of the link's kind is simplified. The constructions stepping row costs 438,693, 395,870 and 385,510 frontend heartbeats per instruction at 16, 64 and 256 instructions (472,527, 433,397 and 424,162 before the conversion) and 6,825, 4,082 and 3,396 kernel heartbeats (7,299, 4,258 and 3,497). With the link fact one pass later the row cost 12 to 15% more than before the conversion.

  • Tests that read or rewrite generated method text go through shared helpers in Tests/GeneratedEvidence.cs, which forge a decoded method through its decoder call or through the raw definition the decoder reads. Every rejection test is kept: a forged decoder is refused by DeclaredValid, MethodShapeValid or ManagedCallsValid, and a changed raw instruction by ScalarFlowValid.

  • Lean decodes ldlen, newarr and numeric, reference and typed ldelem/stelem. Removed arrayLoad, arrayStore, arrayTransfer and managed table operations. Outlines read array views and Unsafe offsets from original CIL sites. Removed NewArray, ClassElement, TypedElementAccess, SpanLength, SpanSlice, SpanItem, ArraySpan, ArrayRange and AddOffset. Lean verifies typed RefillRead. Typed access rejects by-ref-like elements and requires pinned classes or System.String for objects. At 10 instructions numeric access uses 278,864 vs 278,242 frontend heartbeats/instruction. Typed access costs 6–8% less (256,343, 148,602 and 116,353 at 16, 58 and 254 instructions). Element proofs use step_ldelem_any_of_element, step_stelem_any_of_write and their transfer forms.

  • Opcode 143 decodes to .ldelema element readOnly. Adjacent readonly. decodes to .nop and sets the flag. Other pairings and branches into it fail. The step uses the checked element shape and arrayAddress. The extractor reads the operand and prefix at the original site. ElementAddress, MemoryOp.arrayAddress, the lowered ArrayAddress, Arrays.ValidateReadOnly and the scalar readonly window are deleted. Use arrayAddress_of_element and step_ldelema_of_element for the former step_arrayAddress_of_element. Address steps cost 4–8% less. At 512 sites no ScalarFlowValid row costs more: plain addresses 277,254 versus 277,621, readonly addresses 364,641 versus 396,905, block copies 471,028 versus 472,062. Extracted byte offsets roughly doubled the generated bodies for those rows. The examples have 61 methods with ldelema; the self-admission corpus has none.

  • DecodedSummary binds a checked method contract to a method defined from its decoder: the record names the pin, token and type arguments. DecodedAt requires the method at that index, a successful decode to it and a valid reachability mask. An empty body at a missing index is refused (Require DecodedAt to name a method decoded from the record #614). decodedProgram?_eq_some transfers it to the program read from the body bytes, and the site lemma gives a caller the token and type arguments of the callee it links. Examples prove one caller property both by stepping through the callee and through its summary: the generic identity at one and two sites, Arithmetic::Calls, and callers with 1, 4 and 16 calls of a method that writes through a reference. At 16 calls the summary proof costs 52.1M heartbeats with the summary's own proof, binding and decoding included, against 158.4M stepped, and 621,945 kernel heartbeats against 3,228,438. Tests/SummaryCalls.cs fails when the cost per call through a summary grows by more than 1.6 times from 4 to 16 calls or when the summary proof at 16 calls costs as much as stepping. Negative tests refuse a contract whose footprint omits the written cell, a caller that leaves the callee's precondition unproved, a callee whose raw definition is forged, and a summary bound to another method's token.

  • An instance field access whose owner has no carried definition is refused in Lean (unboundInstanceField). Before, the operand check accepted any field name at index 0 for a type of an unpinned assembly or of a contract import, and no other check bound the index to the field the token names: a forged extraction in which ldfld of one field read another field's offset passed the whole evidence check, on the struct path and on the class path, and only the extractor refused it. Item1 and Item2 of the core-library ValueTuple pair keep indices 0 and 1. All 5,065 instance field accesses in the admitted corpus have owners in the module itself.

  • A class instance field typed System.Object or as a generic class is admitted in Lean as the extractor admits it: a class-like generic instance is an application over a head that states it is a class, and binding compares the head with the kind the metadata gives. The 45 corpus methods (88 admitted entries) that Lean refused are accepted. The arity of a generic owner is tied to its GenericParam rows: an owner without parameters carries the adjacent rows that bracket it, so a type definition with parameters named without arguments is refused in Lean and no longer only by the extractor. That rests on the table being sorted by owner, as ECMA-335 requires, which no check reconfirms yet. A method whose signature has no GENERIC flag is read as having none without brackets, as before. Over 60 corpus extractions the brackets cost 1.7 percent of total heartbeats (the tables check 16 percent, the body check 2.3 percent). Tests/SelfAdmission.cs gains an opt-in mode that checks every admitted entry in Lean (about 2.7 CPU-hours; no suite runs it); on 290e747f Lean accepts all 3,760 admitted corpus methods.

  • The generated method{n}_calls_validated theorem is decided in the kernel on ManagedCallsValid, which reads links by one walk. The earlier tactic went through a list form that read each pc's link by a table scan, so its cost grew with instructions times links: 24.1M heartbeats at 125 string tokens and 159.4M at 500. It now costs 3.1M and 9.0M, and the lookups rows bound the whole file and the call check per token at 1.15 (strings 1.04, fields 1.09, calls 1.07).

  • The generated feature theorem states its link lookup as MethodEvidenceValid does. With the two stated differently, assembling the evidence theorem unified them by unfolding the decoded body, about 390,000 heartbeats per instruction; it now costs about 395,000 at 502, 1,002, 2,002 and 4,002 instructions. cil_decoded_method writes an all-zero struct local as List.replicate size 0, the term a literal definition has, so a caller's goal after frame entry is unchanged by decoding.

  • The System.Object constructor is the first entry of the runtime-model table. The base constructor call of a constructor stays one .call with no link, where the extractor lowered it to pop. A call whose method the table models states no link and a call it does not model states the link the call check required before; ManagedCallsValid takes the modelled set and decides both in its one match on the instruction, so a pc that is not a call pays about 79 heartbeats for it. callEmitsNoPop, part of UnsafeCallsValid, refuses pop at a call or construction site, and the runtime catalog lowers nothing. Stepping a constructor's base call costs 18 to 25 percent fewer frontend heartbeats than the pop did at 16, 64 and 256 instructions, and the calls stepping rows 5 to 9 percent fewer kernel heartbeats. Model facts are proved per table entry, so a further entry adds a case. This conversion defines 791 more corpus methods from their decoder.

  • A static site is bound to the field its token names: each static descriptor carries the typed field reference, and the static field check requires the site's descriptor to name the instruction's field for ldsfld, ldsflda, stsfld and field ldtoken. Before, a forged extraction could put one field's descriptor at a site whose token names another, and a static load returned the other field's value. A static whose owner is not carried is refused, except the platform constant the feature check requires verbatim, and a static named through an instantiated owner is refused. StaticIdentitiesValid, a new conjunct of TranslationValid, requires one static identity per field and one field per identity in the whole program, by sorting the pairs in both directions (oneToOne_spec); before, two fields could share an identity and alias in the model. It costs 22,544, 20,876 and 22,706 heartbeats per site at 8, 32 and 128 sites. The extractor reports an instance field operand whose owner is not carried as a blocker with its reason.

  • Program.closure follows method links. MethodContract.Holds.restrict transfers the contract to its closure and DecodedSummary.relocate transfers it to a matching program. The closures suite reuses one proof in three programs and rejects different target bytes. Program.closure_eq_closureWith permits any lookup agreeing with the list. Extractions certify programLength, programIndex (a balanced tree from program_index%) and programIndex_get? in one kernel comparison. Finding n methods and e callees in a program of P takes O(n log P + e). Chains of 8, 32 and 128 methods cost 87,394, 335,656 and 1,422,953 kernel heartbeats (list lookups cost 90,395, 437,519 and 3,533,840). Four reachable methods in programs of 128, 512 and 2,048 cost 55,819, 58,512 and 61,237 (lists cost 81,699, 179,818 and 571,795). The index adds 0.49% to elaboration for Add and 0.10% for 128 methods.

  • DecodedSummary.reprofile binds the same evidence and method identity to an agreeing profile. Independent x64-v3 extractions reuse compiled scalar proofs of addition, a low vector lane and an eight-byte byref write. Both extractions and proofs replay together. A different addition token or add byte invalidates reuse. Re-exporting the same DLL with a +1-or-+2 postcondition changes both closure and interface digests. The cached exact caller fails and the weaker caller verifies against the new digest.

  • Reversing the single branch in compiled Choose preserves both two-instruction return regions. A consumer imports their compiled proofs, checks the changed branch, and proves its result for every Boolean, word pair and caller memory. The consumer cost 2.38M frontend and 285,524 kernel heartbeats. Direct stepping cost 2.79M and 126,232. Compiling the reusable producer cost 8.20M and 197,560.

  • The changed CountCalls initializer starts at one. A consumer reuses the compiled loop invariant, decreasing measure and Decrement proof to prove x + 1 modulo 2³² for every input. The four modules replayed together in 7.0 s.

  • The vector example: DivisionIntrinsics.UnsafeLowNext returns UnsafeLow(x) + 1, and Examples/Proofs/VectorSummary.lean proves it once by stepping through UnsafeLow and its two modelled vector calls and once from a DecodedSummary of UnsafeLow. Stepped it costs 3,192,215 heartbeats (118,705 in the kernel, 3,488 proof objects); through the summary, with the summary's own proof, binding and decoding, 3,506,999 (139,650; 4,614), so one use of a callee this small does not repay the summary. main has no proof of a caller of UnsafeLow to compare with. A forged UnsafeLow that reads the other lane is refused by the body check.

  • Segment contracts (CIL/Safety/SegmentContract.lean): a precondition, a memory footprint and a postcondition over checked exits, with sequential and branch composition and links to weakest-precondition proofs.

  • The stepping tactics keep an index of the equation hypotheses in scope, so the cost of a step no longer grows with them (21 to 61 heartbeats per hypothesis per instruction between 16 and 256 hypotheses), and snapshot walks restate a fixed number of facts per store.

  • Path comparison in the verification scripts follows links and uses the case rule of the volume that holds each path, read from the operating system.

  • An x64 profile below the .NET 11 x86-64-v2 baseline is rejected, and the x64-sse2 profile is removed.

  • StrictBinding: methodMetadataBound and MetadataRowsBound bound the carried rows of a method across pages.

  • Closed argument storage is decided without Classical.choice; that check costs 57% less on Add and 44% less on Countdown.

  • Represent metadata names, UTF-16 user strings, assembly versions and identities with typed values. Preserve raw identity components and use a lawful assembly ordering. Some scoped identity comparisons remain textual.

  • The reference interpreter CIL.step itself gives a mixed int32 and native-int operand pair its ECMA-335 III.1.5 result for sixteen instructions (arithmetic, bit operations, comparisons and signed branches); Safety.step reaches the widening only through it, and Tests/MixedNativeOpcodes.lean proves the two interpreters agree for every operand, both orders and any stack beneath. Unsigned branches still refuse a mixed pair: on .NET 11 the runtime zero-extends or sign-extends the int32 operand of a mixed unsigned branch depending on whether the JIT has it as a constant, and one method changed its result after tier-up, so no single rule matches the runtime.

  • Execute mixed native arithmetic and reference offsets through the bare opcodes: add on a reference and an integer keeps the checked byte-offset semantics of the form it replaces, and Tests/ReferenceTests.lean proves the two equal and rejects the old lowering. add on a native method table and an integer offset, in either order, executes the checked cursor addition; ManagedOp.tableOffset and the C# TableOffset record are deleted.

  • Use opcode-specific arithmetic, conversion and local instructions. Local narrowing comes from declared metadata. Checked return dispatch rejects incompatible narrowing; execution and structural proofs use the shared dispatch. Remove unused vector-home components and dead block helpers.

  • Integrate deep checks into the internal standalone verification path. Retain pinned image snapshots, build StrictBinding in the selected certified library, jointly replay and audit the proof and binding contributions, and include binding evidence in successful reports. verify --deep-checks exposes them, and replay failures are attributed to the declaration that the kernel rejected.

  • StrictBinding checks the carried table header, decoded header, Assembly row and its string and blob entries against the pinned image (assemblyMatches_of_assemblyBound). For slice rows, RowsMatch, rowsBound and rowsMatch_of_rowsBound mask MethodDef RVAs and reject missing or unused heap entries. One sort and merge-join assigns heap keys. Cost per added row grew 1.07× from 256 to 1,024 rows. The corpus covered 88 methods and 949 rows across eleven tables. Metadata roots accept a 256-byte version field.

  • Check pinned SHA-256 digests and PE method-body locations with paged body claims and flat image-list auditing. Validate original library bytes and file sets before cache promotion, including same-length changes with restored timestamps.

  • Keep pinned metadata contexts alive through contract import/export, source-bundle verification, inventory probes and exception linting.

  • Read the metadata table header through the stream directory and the Valid mask, and refuse an uncompressed #- table stream and malformed roots, each with its own error. Carried MethodDef rows keep the body address zeroed, so editing one method leaves the evidence of other methods byte-identical.

  • Every Lean test library has a suite that builds it: 19 libraries that only an all-library build reached are now built by core, evidence or intrinsics, and Tests/Strings.cs, Tests/Identities.cs and Tests/StrictBindingFixture.cs run in a suite.- Build with .NET 11. Share hash operations and reduce repeated work in stepping, embedding, metadata lookup, extraction and audit preparation.

  • BodyDecodes.callManagedTarget resolves a raw operand to a slice and MethodDef. For explicitly scoped owners, DecodedAt.direct_site identifies the callee pin, token and type arguments. App.Direct and Lib.Step share a token. The caller resolves to Lib, rejects App's pin and preserves caller memory through the summary.

Proof-author changes

  • Decoded ldobj and stobj preserve aggregate bytes and initialization flags. Scalar loads and stores use ldind, stind, typed object access or checked call transfers. All four synthetic transfer constructors and their lowering are gone.

  • cil_element_shape% Extracted.method0 2 gives the shape of the decoded array element at pc 2. Generic word-read outlines use the checked instruction at that position, including in methods with unreachable array instructions after the return.

  • Instruction constructors follow ECMA-335 mnemonics: and, or, xor, not, shr_un, conv_i1 to conv_u, ceq, cgt, cgt_un, clt, clt_un, br, brfalse, brtrue, bne_un, bge_un, bgt_un, ble_un, blt_un, ldc_i4, ldc_i8 (argument value), ldloc, stloc and ldloca. Lemmas named after an instruction follow. Unsafe.SkipInit<T> executes as a checked call. The four-word reader and writer use ldfld and preserve their overlap contracts. The standalone Instruction.skipInit and its step equations are removed. Use step_call_skipInit_reference or cil_contract_steps.

  • divide, checkedArithmetic and checkedConvert are replaced by div, div_un, rem, rem_un, add_ovf to mul_ovf_un, and conv_ovf and conv_ovf_un over ConvTarget; conv_i is its own instruction. step_checked_result, step_conv_ovf_result and step_conv_ovf_un_result replace the earlier result lemmas, and guard_div to guard_mul_ovf_un are in cil_guard.

  • ldloc and stloc take only an index; narrowing comes from the slot kind. step_local_annotation and step_setLocal_annotation are removed. ldloca on a span local pushes the view it holds.

  • ret reads its narrowing from the declared return type (Method.returnNarrow, declaredNarrow in CIL/Resolution.lean).

  • add on a reference and an integer, in either order, executes the checked byte offset; step_add_reference_i32_eq, step_add_reference_i64_eq and the read-only and commuted forms state it.

  • add on a native method table and a 32-bit or native offset, in either order, executes the checked cursor addition; it returned invalidState before. step_add_table_i32_eq, step_add_table_i64_eq and step_add_table_commuted_eq state it, and ManagedOp.tableOffset is removed. Extraction accepts the table form only for opcode add with no operand.

  • The first match of CIL.step begins with the two table arms, so a split on step leaves 14 exclusion hypotheses in its last case; it left 12. step_add_commuted_eq, step_add_readOnly_commuted_eq, step_memory_add_commuted_eq and step_memory_add_readOnly_commuted_eq are closed with id rfl. Memory.Renamed.stepReference now depends on Classical.choice. checkedNative_bind is public in FixedStepHelpers.

  • FeatureState is FeatureFacts over a list of index and word pairs, and the entry state has locals := []; featureSuccessors takes the stack; FeatureFlowValid_iff_list is replaced by FeatureListValid, FeatureFlowValid.expand and FeatureListValid.known; checkFeatureSite is removed; factWeakens and factsWeaken are in FeatureLocals.lean. A handwritten feature certificate lists only known facts.

  • CIL.Extraction.linkKeysAscend and linkKeysAscend_bound are keysAscend and keysAscend_bound over any element type. CIL.CodeSuffix.advance and lookup take an implicit element type; generated suffix and instruction facts keep their statements. cil_resolution_facts also declares {m}_argumentAccess{i}, {m}_parameterSuffix{16k} and, with homes, {m}_homeSuffix{16k}, {m}_homesAscend and {m}_localCount, and it fails on homes that do not ascend or on a signature it cannot resolve.

  • CIL.step matches on the instruction and CIL.widenMixed applied to the stack. fallback_relabel, fallback_raise, fallback_appendLocals and Memory.Renamed.stepFallback state values where they stated CIL.widenMixed op values. The CIL.step.eq_N lemmas of the arms that match the stack take the hypothesis widenMixed op stack = pattern, so simp only [CIL.step] needs CIL.widenMixed and CIL.nativePureBinary in its simp set; the generated step_*_eq equations keep their statements. base_relabel_binary and base_relabel_comparison take the instruction first; nativePureBinary_relabel and widenMixed_relabel are removed.

  • CIL.step gives no meaning to local instructions and has no frame parameter; step_feature, step_return, step_intrinsic, step_profile_eq, BaseRelabel, Fallthrough, Branching and the fallback lemmas lose that argument.

  • Removed with no replacement: vectorArg, vectorArgAddr, vectorLocal, vectorLocalAddr, setVectorLocal, lane, laneAddress, setLane, newVector256, asRef, tableAddress, skipInit, init256, bitcast256, mul64, byteToBool, Method.vectorLocals, Method.vectorArgs, Frame.arguments and Address.home. Frame has four fields.

  • A method records its declared signature, layout environment and call links. TranslationValid, MethodEvidenceValid and MethodsChecked take the pin list. Handwritten certificates must supply the metadata evidence.

  • broadcastBinaryMethod, broadcastShiftMethod and the invoke_broadcast* facts take the declared signature and environment.

  • The 23 step equations that hold by unfolding are closed with id rfl, so simp applies them as propositional lemmas; statements are unchanged.

  • The certificate is schema 7, with a binding section of twelve facts and the refutation bound to its method and assembly, and the verify --format json report is schema 2. verify --deep-checks digests.sha256 runs the deep checks; there is no separate audit command. A default verify prints Binding: default and one line per trusted fact.

  • In StrictBinding, body proofs compose through checkAll, ClaimsHold and PagesHold; ClaimedBodiesBound, ClaimPagesBound and claimedBodiesBound_of_pages are removed.

  • Extraction refuses a runtime-async method, body bytes for a row with no IL body, a method generic parameter past the arity, a reference into a pinned assembly whose slice is missing, and an image whose table stream is #-.

  • .arg i is written .ldarg i; its narrowing comes from the declared signature, not from an operand. A closed calli run is proved by cil_kernel_rfl, and a single calli step by step_managed_call_eq with a kernel-checked indirectTarget fact. validateManagedCallWith takes the link read at the site. A mutated declared signature is rejected by method{n}_declared_validated, no longer by method{n}_shape_validated, and argumentAccess_of_evidence takes DeclaredValid.

  • .stackAlloc zeroed is written .localloc, with the flag in declared.initLocals; DeclaredSignature has the field initLocals and StepMetadata the field declared. A CallSite literal states method := { owner, name, hasThis, genericArity, returnType, parameters }; declaringType, hasThis, returnType and parameterTypes are accessors. step_relabel_faulting has a raised heartbeat budget.

  • .unsupported description is written .unadmitted opcode. An exception is a typed value (.throw .overflow, .thrown .argumentOutOfRange); proofs that named exception text name the member. StepMetadata has the field environment; segmentStores, untouchedLocals and SegmentLocalEffects take the body; a homed argument appears as .starg, .ldarga and .ldarg. Generated byte definitions read CIL.Extraction.fixedBytes n 0x...

  • .load64 and .store64 are written .ldind .i8 and .stind .i8; a narrow or native indirect access names its kind the same way.

  • .memory .nullObject is written .ldnull, and .objectTest is written .castclass type or .isinst type.

  • A class field access is written .ldfld field, .stfld field or .ldflda field with a named FieldRef; step_ldfld_eq, step_stfld_eq, step_ldflda_eq and their word, reference and array forms step those opcodes. argumentStep is equationStep.

  • A static field access is written .ldsfld field, .ldsflda field, .stsfld field or .ldtoken; step_ldsfld_eq, step_ldsflda_eq and step_ldtoken_eq state their result as a match on the read, and staticAt is Method.staticAt.

  • step_newarr_i32_eq and step_newarr_i64_eq replace the step_newReferenceArray equations; after stepping newarr a goal shows allocateElements of the element shape.

  • managedStep takes the link of its pc, and an extraction states method{n}_link{pc} facts.

  • run_mono, invoke_mono and invoke_unique take Stable. ExampleProof.outside_neither_returns_nor_throws proves that the interpreter cannot return or throw at any fuel for a receiver outside the dispatch table. Its CLR behavior remains unknown. A fault used for contract.Refuted or RefutedCLR must be definite. Use of_return, of_fault or of_diverges for a refutation. MethodContract.Refuted.of_fault replaces not_holds_of_fault. A rejected gate variant needs a production theorem that states the contract's Holds.

  • A proof that stepped an intrinsic call by unfolding step rewrites with step_intrinsic_eq.

  • A method defined by cil_decoded_method gets its step equations from cil_instruction_equations; the command takes the field references the method names.

  • An object or aggregate construction is written .newobj constructor with a MethodRef; step_newobj_eq states its step as a match on the link of its pc, and after the link fact rewrites the goal shows the earlier do-block with constructor.parameters.length where the literal argument count was. step_newAggregate, its action form and run_newAggregate_of_contract are step_newobj_aggregate, step_newobj_aggregate_action and run_newobj_aggregate_of_contract, and the first and last take an aggregate link premise. objectSiteType, StepEffect, StepContract and SiteConsistent take a pc; step_callee concludes readsLink. An extraction writes method{n}Links, methodEvidence.links and method{n}_links, and its decoder call takes the table.

  • A direct call is written .call method prefixes with a MethodRef; .tailCall is .call method { tail := true }. step_call_eq states the step as callStep of the link at the pc. Forwards, ForwardsOut and WP.load_call_store take the call's MethodRef and its arity, and MethodIdentity and StructuralLabels state call facts over the MethodRef. A body built with Method.withCode has no link at a call or newobj pc until its links are stated. validateLinkedCallWith checks both instructions; callOf?, construction?, ManagedCallsValid.reads, ManagedCallsValid_of_implied, all3_implied and ManagedCallsValid.linkAt_eq are removed. A supplied body.linkAt pc = link fact rewrites with the step equation.

  • An element load or store is written .ldelem kind, .stelem kind, .ldelem_ref, .stelem_ref, .ldelem_any element or .stelem_any element, and a length read .ldlen. step_arrayLoad_of_element, step_arrayStore_of_write and step_arrayStore_i64_of_write are arrayLoad_of_element, arrayStore_of_write and arrayStore_i64_of_write. ldelem.i on a null table with a scalar that is not an index gives invalidState where it threw a null reference. Instruction.typeTest? is ofType?, and Memory.Renamed.managedStep lost an unused argument.

  • cil_contract_steps skips a local invocation fact whose start memory is a different variable from the memory the call steps from; kernel heartbeats on the shared tactic libraries are unchanged. In a proof with several summarised calls, clear the earlier frame once the next call's frame exists. LocalSnapshots.read_word64 reads a remembered 64-bit local.

  • cil_checked_steps steps a call without a link on in the same method. With the link fact and the model fact the stepper rewrites a modelled call by step_call_model, and a directly linked .call by step_call_direct; step_call_eq remains for a call whose link no fact decides. callStep takes an argument for the unlinked case, and the cil_managed_calls macro is removed.

  • TranslationValid has the conjunct StaticIdentitiesValid and translation_of_methods a parameter for it; BodyEvidence has the field statics; a linked static collision is the typed StaticCollision; MetadataIndex.link is IndexTables.link. The metadata errors unboundInstanceField, unboundStaticField and instantiatedStaticField are new.

  • SegmentState.localFootprint takes the body. The x64-sse2 profile no longer exists; x64-sse42 is the lowest x64 profile.

  • Runtime calls use .call or .newobj. Use step_call_model, step_call_intrinsic or step_newobj_model. modelStep_memory steps a bound memory helper. cil_loop_advance and cil_contract_steps step them in the caller frame and report the failing model step.

  • MethodEvidenceValid has no profile conjunct and the generated profile_valid term is gone; MethodEvidenceValid.profile_valid derives the fact from the shape check. ExactHardwareRegistered is HardwareRegistered and covers every hardware slot. A call or construction with neither a link nor a runtime model fails with "has neither a link nor a runtime model, so no step crosses it", and its failure record says "missing":"linkOrModel". A rejected verify-batch request names the verified request it refutes (refutes) and passes only on a kernel-checked MethodContract.Refuted of that request's statement; a build or extraction failure fails the row. Instruction.ofRaw? gives .nop for a valid unaligned. and copyBlock or initBlock for cpblk and initblk, and blockAlignment is new.

  • A generated Templates.lean holds, per input, pinned metadata, raw bodies and a cil_decoded_method, and proves for each selected input that the template's code is that input's decoded code. The 30 exact-binding statements are unchanged, and 2,927 of 2,928 instruction equations are textually the same (one literal reads ldc_i8 0). Checking a template costs 52,427 heartbeats per instruction at 502 instructions against 13,108 for the literal form, linear in inputs and flags. Proof outline stops and exception lint origins print the CIL instruction as Cecil spells it (IL_0001: stloc.0).

  • ldloca and ldarga of a span slot push Value.spanHome slot, and each use reads the slot's current view (spanView). A span constructor called on a home runs as the model RuntimeModel.spanInPlace and writes that slot. Instruction.initializeSpanLocal, its five step lemmas and the lowered call families are gone; a span initobj decodes as initobj. checkedValue refuses a home, so checkedValue_of_valid, checkedValues_of_valid, run_load_arguments, step_call_loaded, MethodContract.Holds.forward and forward_out take a hypothesis that their values are not homes. modelStep_frame replaces modelStep_next: the frame is unchanged, or spanInPlace set one span slot to a new view of the same width and writability.

  • Each validated record decodes to the whole executable method, including its argument homes. Runtime call agreement follows from decoding and the feature mask. The generated runtime theorem keeps its name.

  • A method or outcome summary can use the translation certificate and one method lookup. The compiled Bump example binds the account update and null-receiver exception to the same body. An agreeing profile can reuse the outcome proof when the same evidence decodes to the target.

  • A direct or relocated summary requires the destination record's BodyDecodes proof. Changing only the assembly label breaks the binding. The translation constructor takes this fact from the existing certificate.

  • DecodedSegmentSummary binds a nonempty sequence at an exact PC to the decoded method. Its contract retains the entry stack, frame, footprint, returns, definite faults and divergence. A closed region can reuse the proof after a prefix changes when its instructions, method metadata and callees agree. The adder fixture swaps the two loads before the region. Changing the add or return convention fails the check. Adjacent summaries compose when the boundary states and permitted writes agree.

  • A recurrent region that consumes positive fuel at each visit proves divergence for every budget. A checked entry prefix carries that proof to a method contract.

  • Kernel-checked counterexamples cover arithmetic, conversions, branches, loops, generics, exceptions, copies, snapshots, byref writes, dispatch and SIMD. Countdown and CountCalls variants exhaust every fuel budget. SSSE3 and AVX2 shuffles preserve overlapping 16- and 32-byte readable spans. Both AVX2 reads reject Vector128.Create<byte>. Reversed SSSE3 operands, swapped AVX2 halves and ignored AVX2 mask bit 7 each have a compiled counterexample. AVX-512 SignWindow selects four limbs or their sign extension for all inputs and selectors on x64-v4. With limbs [0,1,2,2⁶³] and selectors [4,5,6,7], low-sign broadcast returns zeros. Swapping tables or choosing by bit 3 returns the input limbs. All three refute the required four all-one words. Unsupported execution stays inconclusive for CLR contracts. Stable interpreter results retain model-level uniqueness.

  • Extraction and templates require successful decoding. A refused live instruction reports the method, IL offset, opcode and PC. The blockers report drops literalMethods. MethodEvidenceValid.code_eq and .staticSites_eq apply to every method. The decoded flag and ScalarFlowValid.of_decoded are gone.

  • Method.ofClosed? returns Except MethodDecodeError and refuses a method with a reachable hole (liveHole pc opcode); Method.ofRaw? then gives none. A span ldobj forwards only a span value and storageLowering? takes the stack. Unsafe.As needs field or vector storage on both arguments. callModelled takes an opcode and method pair. ExactIntrinsicsValid and methodN_intrinsics_validated are replaced by runtimeModels_exactHardware. Decoded signatures share layout identity bytes and scope constants, so rfl closes a run through a model at default limits. Extracted.lean sets maxHeartbeats on instruction checks when 120 per instruction plus 432 per call site exceeds 200,000.

Fixes for failed CI runs

  • Deep report tests use each binding request’s coverage predicate, including generic constraints and layouts.

  • MemoryMarshal rejects newobj at a call site. Array sum proofs accept PDB and fallback locals.

  • Argument homes follow locals. Lean refutes 14 offset and 12 transfer obligations from the failing declaration and its premises.

  • Integer-math wrappers supply the checked call model to the shared step tactic. The enum fixture uses the two-argument span constructor lookup. The math suite passes 21,804 CLR comparisons. Verification run 44909487654 also recorded a six-heartbeat difference across scalar stepping repeats. Kernel counts and proof bytes matched on all three repeats.

  • InstructionIndexes covers both blt encodings, closed scalar types, signed loads and stores. Aggregate ldfld uses checked snapshot equations. The 13 dispatch fixtures and forged local passed. Eight compiler columns cover 26 more imports standalone and pinned.

  • Template indexes include static layout. The library reader checks Windows paths, eviction and entry hashes.

  • Struct returns use declaredNarrow_eq_storage. The stepper checks derived stind facts. Generic field operands resolve to their definitions.

  • CLI packing isolates builds and checks the extractor hash. Seven forged-scope fixtures use assembly references. CI uses measured suite times, scaling checks count work and generated regexes use static partial properties.

Measurements

  • Generic import kernel heartbeats fell from 344.6M to 6.0M for the body and 49.2M to 2.3M for calls.

  • Direct explicit/packed reads: 1,279,438/1,264,256 kernel heartbeats vs 64,722 at 27953ed (CIL.Op). Applications: 7,700/7,695 in both. Reusing field shapes cuts gate proofs to 168,478/177,597 (−86.5%/−85.6%). Both relocations refute.

  • Countdown at 4/16 costs 643,032/1,783,100 directly versus 485,216/1,530,394 CIL.Op heartbeats. Both use 145 per contract application. Both have identical CIL.

  • At 254 instructions, typed Math.Max calls cost 138,235 frontend and 2,565 kernel heartbeats/instruction (previously 138,215 and 2,565).

  • Main 27953edb and PR 400710a2 took 9,200 and 23,988 aggregate seconds across 79 matching suites. CLI rose from 199.2 to 1,580.2 s and workspace from 162.7 to 214.3 s. Default verification skips deep checks.

  • Confined.frame_round_trip carries an empty-footprint contract across a callee that preserves every pre-existing allocation. The compiled SignWindow and unsigned Less proofs each use 103 fewer proof objects. SignWindow frontend/kernel heartbeats fell from 8,849,109/998,273 to 8,811,283/997,462. Less fell from 6,637,333/1,112,951 to 6,606,512/1,112,132.

  • On the same struct field, writable address formation took 180,627 frontend and 5,494 kernel heartbeats (182,698 and 5,862 before), and readonly took 173,538 and 5,416 (175,532 and 5,784 before). On Automation, StoreFacts, MethodContract and CodeAt, the four shared tactic tests, each frontend total fell and each kernel total held or fell.

  • Changed CountCalls and byref Mutate have identical CIL offsets, instructions and locals on main (.NET 10) and here (.NET 11). In order: old CIL.Op, direct canonical proof, compiled-summary consumer. CountCalls frontend/kernel heartbeats were 12.74M/873,910, 12.45M/760,588 and 7.06M/258,516. Module sizes were 714/764/287 kB, elaboration 2,042/2,276/961 ms and standalone replay 7.0/11.9/13.7 s. The producer cost 22.22M/919,933 heartbeats.

  • Mutate adds two and confines the write to its eight-byte footprint. In the same order, frontend/kernel heartbeats were 2.73M/93,374, 2.74M/78,043 and 177,252/30,919. Modules were 173/179/30 kB, elaboration 520/561/63 ms and standalone replay 9.0/12.1/12.2 s. The scalar producer cost 2.79M/81,223 heartbeats. Both comparisons use one timing per module.

  • Applying Lib.Step's summary in App.Direct costs 1,918,794 frontend and 69,536 kernel heartbeats. Direct evaluation of the same arbitrary-memory contract costs 2,221,314 and 364,123. Proving the summary costs 1,594,739 and 285,938.

  • Step equations used 40–64% fewer kernel heartbeats per instruction and 4–21% more proof bytes.

  • Across 36 matched stepping workloads, the return-dispatch change increased frontend heartbeats by at most 0.2967% and kernel heartbeats by at most 0.4098%.

  • Checking one generated Extracted.lean costs 2 to 2.3 times what it costs on main (Add: 4.8M to 11.3M heartbeats). Of the 6.5M added for Add, 4.6M elaborate the literal metadata, name and table bytes and 2.0M run the checks; the checks of the lowered program, 2.4M to 16.4M per file, are still carried beside the decoded evidence.

  • cil_decoded_method preserves the Add, Choose and Countdown proofs, correctness theorem heartbeats and axioms. Before field decoding, deriving a method cost about 45,000 heartbeats per instruction, 4.1–4.3 times the emitted literal and facts. Extraction cost rose 6.0–6.6%, above the 5% threshold, because computing and kernel checking the literal each ran the decoder.

  • Reusing the swapped-load add region cost 232,813 frontend and 25,193 kernel heartbeats. Restep cost 322,632 and 44,371 with the same destination binding. Proof terms had 617 and 518 objects.

  • Deriving runtime call agreement and binding the full method changes elaboration heartbeats by +0.40% for Add, -2.63% for Add17nint and -0.60% for TraceNarrow, measured against the decoder-only extractor. For the canonical four-word reader, frontend/kernel heartbeats rose from 7,039,350/238,860 to 7,937,633/606,297. For the writer they rose from 8,255,186/272,725 to 8,676,160/640,301. Automation, StoreFacts, MethodContract and CodeAt each moved by at most 345 frontend heartbeats. CallingFields rose 6.60%.

  • Summaries against stepping and against main (27953edb, CI run 43422873269). Heartbeats, with kernel heartbeats in brackets; a summary row includes the summary's own proof, its decoding and its binding. CountCalls: main 10,373,560 (655,554), stepped here 9,807,269 (453,183), through a summary of Decrement 9,949,785 (240,803). Identity64: main 1,543,005 (64,260), stepped 1,556,811 (57,833), summary 2,051,844 (87,160). Repeated: main 2,398,448 (68,830), stepped 2,424,688 (63,273), summary 2,478,344 (103,540). Nested: main 2,414,643 (80,782), stepped 2,440,469 (73,854). Calls for every input, which main does not prove: stepped 8,361,015 (347,408), summary 9,292,411 (237,414). In those examples, single-use summaries cost more frontend heartbeats. Only Calls and CountCalls save kernel work. At 16 calls to one callee, reuse costs 52.1M against 158.4M. Proof objects and module sizes: CountCalls 20,489 objects on main, 18,145 stepped and 11,072 through the summary, in a module of 664,616 bytes on main and 897,144 here; Identity64 2,193, 2,399 and 3,612 objects.

  • On one input, Calls by rfl costs 1,882,199/524,220 frontend/kernel heartbeats versus 1,412,152/374,759 on main (+33%/+40%).

  • 3,378/12,560 self-admissions and 6,081 fixtures decode. 18 class refusals match. Constructors: 2 outlines, 25 outline and 1 extraction refusal. Prior outlines/refusals: 13/63, arguments 14/2, switch/return/throw 30/2, objects/arrays 8/12. Lean checks repeated targets in byte order. Dispatch: 501 definitions, 52 families, 2,026 cases. M4: 100 calls at 125/500 classes took 0.13/0.14 s (from 0.30/0.80 s).

Remaining work

Linux and Windows scalar16: 65,887 kernel heartbeats, frontend counts differ by six.

Not verified

  • Transfers passed 730 Lake jobs, eight shared suites on the aggregate-store commit, and 50 unaligned-memory checks. All 61 admission checks and 47 ConstrainedCalls proofs plus negative controls passed. TupleSize binds both argument scopes. Eight generic layouts passed their forgery checks. DivRem passed 500 hardware and 562 Math cases. Both universal quotient proofs hold. Both compiled remainder variants return 1 for 7 / 3, refuting the required quotient of 2.
  • All 12 checked arithmetic variants, 26 branches and 14 vector/profile cases kept their expected results. All 11 guard and endian comparisons matched. Of 38 memory cases, 36 produced identical extractions and outlines and two retained their expected refusals.
  • Not measured: the structural arm of cil_managed_calls on extracted evidence after the link walk change; the heartbeat comparison on the shared tactic tests after the hole, localloc, starg and ldarga arms joined the first match of step; Tests.StoreFacts and the loop suites after the typed exception change; the linked first pass for instance, virtual and managed calls (the stepping rows exercise call only).
  • At 64, 256 and 1,024 sites the managed-call check costs 14,906, 13,311 and 12,913 heartbeats/site (10,585, 9,105 and 8,734 before the call conversion). At 256 sites, table shape costs about 1,650/site, walking the zipped lists 4,050, the first link read 2,560 and link fit 2,200.
  • A Debug extractor in Extractor/bin makes Tests/SelfAdmission.cs -- --update record an empty baseline and report success (Keep Debug builds of the extractor out of Extractor/bin #624).
  • The closure benchmark excludes index construction, and statics step without site facts. Lean and the extractor both reject a live class ldflda, including on a closed generic class. The kernel checks MethodSpec argument counts against the declaration. The decoded-only gate manifest digest remains open.

@benaadams benaadams added feature Adds a capability area: proofs Lean proof API, contracts and tactics labels Nov 14, 2026
@benaadams benaadams changed the title feat(extraction): check extracted methods against their decoded CIL bytes feat(cil): add decoded body checks, metadata binding and typed identities Nov 14, 2026
@benaadams benaadams changed the title feat(cil): add decoded body checks, metadata binding and typed identities feat(cil): add decoded body checks and typed metadata identities Nov 14, 2026
@benaadams benaadams changed the title feat(cil): add decoded body checks and typed metadata identities feat(cil): check decoded bodies and typed metadata identities Nov 14, 2026
@benaadams benaadams changed the title feat(cil): check decoded bodies and typed metadata identities feat(cil): validate decoded bodies, metadata and deep proof bindings Nov 14, 2026
@benaadams benaadams changed the title feat(cil): validate decoded bodies, metadata and deep proof bindings feat(cil): migrate execution and proof bindings to decoded CIL Nov 14, 2026
@benaadams
benaadams force-pushed the feat/canonical-cil branch 2 times, most recently from 7d392ae to 6f13572 Compare November 17, 2026 14:49
Require a static method at ldftn so decoding preserves the callable
signature. Check that the address of an instance method with no explicit
parameters cannot produce a parameterless static pointer.
Render closed callable arguments with the type encoder used for raw
specialization evidence. Preserve the class tag and scoped name and use
layout slot zero for callable aggregate identities. Compare the literal
identity of M<Account> with the address produced by the Lean decoder.
Check the numeric replacement of a managed address with the address
link removed. Retain the replacement with its link as a separate check
of the instruction's link kind.
Advance a cursor when an instruction reaches the next explicit link.
Use its position to select the suffix for an unlinked call. Membership
and insertion-position lookup now take one pass over the instructions
and links when generating absence equations.
The self-admission corpus admits 3,801 extractor methods and all of them are defined from their decoder. The example counts stay at 1,145 of 1,198 scalar, 1,154 of 1,223 for x64-v3 and 1,153 of 1,208 for arm64-advsimd.
The tuple identity and the row result identity of Math.DivRem are written as interpolated strings. The evidence document says what a marshal site with no resolving overload becomes at a linked position: the decoder keeps the call and ManagedCallsValid refuses the method.
A body of 802 instructions with a linked call at every second one spends 168 heartbeats per instruction on its instruction checks, 104 of them in the model agreement check, against 60 for an arithmetic body. The budget stated on those checks is now 400 per instruction and applies to a method of more than 500 instructions, so a long body of calls stays inside it.
The operand checks and the marshal evidence state the option type of each indexed read they match on, and the marshal evidence names its changed site before building the changed instruction, so Lean reads the patterns and the structure literal.
Bind each open declaration, external target and closed range signature in
one reserved call entry. Resolve the element and stride from checked
array storage and layouts. Execute the same checked array operation for
every stack, including null, invalid ranges and expired backing storage.

The decoded instruction is a call at all three overloads. Array layout
evidence comes from the model reader. Remove arrayExtensionCall and
the AsSpan lowering and layout-use arms. Check the decoder on each
overload and on raw operand and layout mutations.
The examples assembly decodes 1152 of 1198 scalar methods, 1161 of 1223 for x64-v3 and 1160 of 1208 for arm64-advsimd. The self-admission corpus decodes 3801 of 3801.
Read each modelled call as its operation at the original pc. The loop
walk shares the checked stepper's link lookup and executes an unlinked
call through its model fact. A linked call still uses its contract.

CopyUntilZero advances through get_Item at pc 5 to Stamp at pc 19.
The native-size getter regression checks that the first of two calls
to the same operand pushes 8 and the second stops at its link.
Bind the endian constant to the profile and the exact runtime field.
Decode RVA addresses and handles from their field and storage descriptors.
Resolve RuntimeHelpers.CreateSpan through its typed generic declaration.

Four more example methods decode on each profile. Scalar reaches 1149 of
1198, x64-v3 reaches 1158 of 1223, and arm64-advsimd reaches 1157 of
1208. All previously decoded examples retain their decoder definitions.
Match Instruction.call explicitly and name the altered call site before
placing it in the raw instruction. All five aggregate MemoryMarshal
evidence cases elaborate. Each case checks the original emission, the
forged declaration and both candidate memory operations.
Keep Clear and Fill on writable spans, CopyTo and TryCopyTo on both
span owners, and both generic Array.Fill overloads as calls. Seven
reserved table entries bind eight open declarations and external targets.
The closed signature selects the overload. The checked layout supplies
aggregate widths. The interpreter uses the original stacked receiver
and the same memory operation for overlap, bounds, faults and counts.

At a byte copy site the instruction goal changes from .memory
(.spanCopy 1 false) to .call target {}. TryCopyTo uses .spanCopy 1 true
as its model. At a word fill or clear site .memory (.spanFill 4 false)
or .memory (.spanFill 4 true) becomes .call target {}. At an array
fill site .memory (.arrayFill .signed32 false) or its counted true
form becomes .call target {}. Use step_call_memory with the unlinked
pc and the generated method0_model2 fact at pc 2 to recover the same
stack, frame, memory and fault goal. Concrete fault and return proofs
use cil_kernel_rfl where rfl exceeds the elaborator recursion limit.
Reinterpreted span and view accessor proofs use the same kernel check
for their closed invocation results.

At an aggregate copy pc, a .size pc index .spanElement layout-use row
becomes a model fact with the checked width. A forged width is checked
against that fact. RuntimeModelsAgree checks the emitted call and the
raw declaration. The synthetic decoder tests check the call hole for
each altered overload. The generated examples check their model facts.

Each profile gains 22 decoded methods and loses zero. The decoded counts
are 1167 of 1198 on scalar, 1176 of 1223 on x64-v3 and 1175 of 1208
on arm64-advsimd.
The examples assembly decodes 1178 of 1198 scalar methods, 1187 of 1223 for x64-v3 and 1186 of 1208 for arm64-advsimd. The 20 scalar methods that keep a literal stop at a span constructor.
Decoded calls share their layout row's UTF-8 identity. Storage compares
four bytes at a time and ASCII scope decoding checks the bytes before
constructing characters. Projected results have decidable equality.

Math.DivRem(1, 1) reduces by rfl at the default depth of 512. The
literal call needed 579. The 221-byte generic tuple size and five
model families have closed execution checks.
A positional layout read stops at the requested row or the end of the
list. Compiled code uses native array indexing by a proved equation.

At both 16 and 256 entries, first, middle and last model lookups need
depth 75. A size query on the last layout needs 210 at both sizes.
The model fact check of a call site states the model through the raw operand at its position. The proof now requires the generated model fact for the expected model and lets the kernel compare the two sides, because the elaborator exceeds its recursion limit indexing a long literal code list near its end.
Tests.UnsafeReinterpretations is a lean_lib that no suite built, so its
theorems were not checked in CI. Build it in the core suite beside
Tests.UnsafeModels, Tests.UnsafeOffsets, Tests.UnsafeTransferModels and
Tests.UnsafeBlocks.
A span ldobj returned any operand unchanged, so a Span-typed byref
argument formed by Unsafe.As<long, Span<byte>> or Unsafe.NullRef reached
the callee as a plain or null reference and the call returned normally.
transferObject now forwards only a span or buffer span view. A null
reference raises nullDereference and any other operand raises
invalidState.

step_ldobj_span now takes a bufferSpan view. step_ldobj_span_value,
step_ldobj_span_null and step_ldobj_span_address state the other arms,
and step_ldobj_span_result states the step on every stack.
storageLowering? takes the stack and lowers a span load to nop only when
the stack's head is a span view, so cilSteppedOp and the loop automation
no longer lower a span load without a stack.
Memory.Renamed.transferObjectResult keeps its statement and splits the
new arm on the stack.

The tests run the span load, every span member receiver and the object
instructions on span, array and class types with null and plain
references, and each faults.
Unsafe.As resolved for a span, array or class type argument, so the two
method program G(ref long x) => F(in Unsafe.As<long, Span<byte>>(ref x))
passed every evidence check. The reference it formed is not the address
of bytes the other type can name. As now resolves only when both type
arguments have field or vector storage, and any other site decodes to
the call hole.

The extractor rejects a span, array or class type argument of As or
AsRef with the element-width check its other Unsafe models use. AsRef of
a span previously produced evidence that failed FeatureFlowValid.

asArgument is removed. The examples decode the same methods under every
profile: scalar 1145, x64-v3 1154 and arm64-advsimd 1153.
Resolve struct field outlines from the original CIL sites and remove their copied representation. Reuse the checked field layout in the read contract and its relocation refutations.

Bind direct local interfaces in virtual class catalogs to their physical metadata rows. Verify the four-word Vector128 comparison and its swapped-word counterexample.
… swaps

Read argument loads from their original CIL instructions and remove the Arg outline record. Bind direct local interface MethodImpl rows to their owning class and exact declaration. Prove and refute compiled half-swap variants and measure reuse of the canonical region proofs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: proofs Lean proof API, contracts and tactics feature Adds a capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant